import request from '../../utils/request';
import { sign } from '../api';
import { stringify } from 'qs';

export async function queryProductJD(params) {
  return request(`/api/product/product/getJDCategoryProducts`, {
    method: 'POST',
    body: sign(params),
  });
}


// 上传sku码
export async function importProductBySku(params) {
  return request(`/api/product/product/addProductBySkus?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    body: params,
  });
}

export async function getJdBalance() {
  return request(`/api/product/product/getBalance?&sign=${sign()}`);
}

//---分类图标API---

//查询1,2级分类
export async function getAllCategory(params) {
  return request(`/api/product/category/all?${stringify(params)}&sign=${sign(params)}`);
}

//查询3级分类
export async function getThirdCategory(params) {
  return request(`/api/product/category/thirdCategoryList?${stringify(params)}&sign=${sign(params)}`);
}

//批量下线
export async function batchOfflineCategory(params) {
  return request(`/api/product/category/batchOffline?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    body: params,
  });
}

//编辑分类
export async function updateCategory(params) {
  return request(`/api/product/category/updateCategory?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    body: params,
  });
}

//下线
export async function offlineCategory(params) {
  return request(`/api/product/category/offline?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    body: params,
  });
}

//上移
export async function upCategory(params) {
  return request(`/api/product/category/up?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    body: params,
  });
}

//下移
export async function downCategory(params) {
  return request(`/api/product/category/down?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    body: params,
  });
}

//添加
export async function addCategory(params) {
  return request(`/api/product/category/add?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    body: params,
  });
}

//不保存3级
export async function saveThirdSortCategory(params) {
  return request(`/api/product/category/saveThirdSort?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    body: params,
  });
}

//保存3级
export async function notSaveThirdSortCategory(params) {
  return request(`/api/product/category/notSaveThirdSort?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    body: params,
  });
}

//保存1,2级
export async function saveSortCategory(params) {
  return request(`/api/product/category/saveSort?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    body: params,
  });
}

//不保存1,2级
export async function notSaveSortCategory(params) {
  return request(`/api/product/category/notSaveSort?sign=${sign(params)}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
    },
    body: params,
  });
}

//---end---